﻿#ifndef _CQUADTREE_
#define _CQUADTREE_
#include "QNode.h"
#include <set>
#include<set>

class CQuadtree
{
public:
	QNode *_rootNode;
	list<GameObject*> _viewportObjects;
	list<GameObject*> _colObjects;

	// get list object in viewport, objects can duplicate
	void GetObjects(CRect viewport, QNode* node);
	void GetCol(CRect , QNode* );
public:
	CQuadtree();
	~CQuadtree();
	CQuadtree(CRect Rectworld);	
	
	QNode* getRootNode();	
	void setRootNode(QNode* p);

	// add gameobject to quadtree
	void Insert(list<GameObject*>);

	// return list objects in viewport after remove duplicate
	list<GameObject*> GetObjectsInViewport(CRect viewport);
	list<GameObject*> GetColisionObject(CRect rect);
	// 1. get objects: _listObjects
	// 2. get child objects of each objects and insert it to _listObjects
	// 3. clear list child objects của each objects
	// 4. game update
	// 5. process objects and collision
	// 6. remove die objects _listObjects 
	// 7. insert _listObjects to quadtree
	// 8. clear _listObjects
};

#endif